package com.yunji.aggregate.model.dto.analysis;

import com.yunji.common.base.PageDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;

/**
 * @author : peter-zhu
 * @date : 2024/12/27 13:51
 * @description : TODO
 **/
@Data
public class StatisticsCommonParam extends PageDTO {
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "开始时间")
    private LocalDate startTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "结束时间")
    private LocalDate endTime;

    @ApiModelProperty(value = "1 日   2 月  (默认日)")
    private Integer timeScopeType = 1;

    public String getSqlDateFormat() {
        if (timeScopeType == 2) {
            return "%Y-%m";
        }
        return "%Y-%m-%d";
    }

    public LocalDate getEndTime() {
        if (endTime != null)
            return endTime.plusDays(1);
        return null;
    }
}
